<template>
	<view>
		<!--标题栏-->
		<bar-title bgColor="bg-white" :is-back="false">
			<block slot="content">设置</block>
		</bar-title>

		<view class="cu-list menu sm-border margin-top">
			<view class="cu-item arrow" @tap="personalTap">
				<view class="content">个人资料</view>
			</view>
		</view>
		
		<!--按钮-->
		<view class="bg-white zaiui-footer-fixed zaiui-foot-padding-bottom">
			<view class="flex padding-sm flex-direction">
				<button class="cu-btn bg-red" @click="logout">退出登录</button>
			</view>
		</view>
		
	</view>
</template>

<script>
	import barTitle from "../../components/common/bar-title";
  import {getUser} from "../../common/http";

  export default {
		components: {
			barTitle
		},
		data() {
			return {
				skin: true,
			}
		},
		onLoad() {
			
		},
		onReady() {
			uni.pageScrollTo({
			    scrollTop: 0,
			    duration: 0
			});
		},
		methods: {
			SwitchSex(e) {
				this.skin = e.detail.value
			},
			realNameTap() {
				uni.navigateTo({
					url: "/pages/real_name/index"
				});
			},
      logout(){
        uni.removeStorageSync("userInfo")
        uni.removeStorageSync("userId")
        uni.showToast({
          title: '退出成功',
          icon: 'none',
          duration: 2000,
          success: function () {
            uni.redirectTo({
              url: '/pages/index/index'
            });
          }
        });
      },
			personalTap() {
        uni.getStorage({
          key: 'userId',
          success: function (res) {
            const userId = res.data;
            if (!userId) {
              uni.showToast({
                title: '请先登录',
                icon: 'none'
              });
              return;
            } else {
              uni.navigateTo({
                url: "/sub_pages/my/personal-data"
              });
            }
          }
        });

			}
		}
	}
</script>

<style lang="scss">
</style>
